package com.boodaba.todocarts.domain;

public class DrivenByTitle<T extends DrivenByTitle<?>> {
	protected String mTitle;

	public DrivenByTitle() {
		this(null);
	}
	
	public DrivenByTitle(String title) {
		setTitle(title);
	}
	
	public void setTitle(String newTitle) {
		mTitle = newTitle;
	}
	
	public String getTitle() {
		return mTitle;
	}
	
	@Override
	public String toString() {
		return getTitle();
	}
	
	public Boolean identicalTo(T dbtToCheck) {
		if (dbtToCheck == null) {
			return false;
		}
		
		if (this.equals(dbtToCheck)) {
			return true;
		}
		
		return (new DbtIdSpecification<T>(this.mTitle)).isSatisfiedBy(dbtToCheck);
	}
}
